<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class SHU extends CI_Controller {

 function __construct()
 {
   parent::__construct();
   $this->load->model('muser');
   $this->load->library('form_validation');
   $this->load->library('pagination');
 }
 function index(){	 
	 $roles=$this->session->userdata('roles');
 	 $config['base_url'] = base_url().'SHU/index'; 
	 $config['total_rows'] = $this->muser->num_rows('SHU');
	 
	 $config['per_page'] = 10; // xác định số record ở mỗi trang  
     $config['uri_segment'] = 3; // xác định segment chứa page number  
	 $this->pagination->initialize($config); 
	 $data['result']=$this->muser->getalldata('SHU',$config['per_page'],$this->uri->segment(3));	
         if($roles==0||$roles==1)
         {
	 $this->load->view('_header');
     $this->load->view('SHU/SHU_view',$data); 
     $this->load->view('_footer');
         }
     else
         {
             $data['ban_roles']="You haven't this role";
             $this->load->view('_header',$data);
             $this->load->view('notAllowRole');
             $this->load->view('_footer');
         }
 }

 function insert(){
 		$DT=array(
					"SHU_ID"=>$this->input->post('SHU_ID'),
					"E_SI"=>$this->input->post('E_SI'),
					"E_HI"=>$this->input->post('E_HI'),
					"E_UI"=>$this->input->post('E_UI'),
					"C_SI"=>$this->input->post('C_SI'),
					"C_HI"=>$this->input->post('C_HI'),
					"C_UI"=>$this->input->post('C_UI'),
					"EffectiveDate"=>$this->input->post('EffectiveDate')				
			);			
		$this->muser->addData('SHU',$DT);
		$data['error']='Insert successful!';
		redirect('SHU/index');
 }	
 function delete($SHU_ID){ 	
 		$this->muser->delColumn('SHU','SHU_ID',$SHU_ID);
		redirect('SHU/index');
	 }
 function edit1 ()
 {
 	$DT=array(
					"SHU_ID"=>$this->input->post('SHU_ID'),
					"E_SI"=>$this->input->post('E_SI'),
					"E_HI"=>$this->input->post('E_HI'),
					"E_UI"=>$this->input->post('E_UI'),
					"C_SI"=>$this->input->post('C_SI'),
					"C_HI"=>$this->input->post('C_HI'),
					"C_UI"=>$this->input->post('C_UI'),
					"EffectiveDate"=>$this->input->post('EffectiveDate')				
			);	
	$this->muser->updateData('SHU','SHU_ID',$DT['SHU_ID'],$DT);
	$data['error']='Edit successful!';	 	
	redirect('SHU/index');		
 } 
 function edit($str)
 {	
 	$result=$this->muser->getRdata('SHU','SHU_ID',$str);
	$data['result']=$result;	
 	$this->load->view('_header');
	$this->load->view('SHU/editSHU_view',$data);	
	$this->load->view('_footer');
 }
 
 function check_SHU($str){
 		return $this->muser->checkData('SHU','SHU_ID',$str);		
 }
 }